﻿@using System.Diagnostics
@inherits LayoutComponentBase
@layout MainLayout
@inject Interfaces.IRatScannerUI RatScannerUI
@inject IJSRuntime JSRuntime;

<div style="width: 100%; height: 100%">
	<MudLayout>
		<MudAppBar Elevation="1" Bottom="false" Dense="true">
			<MudIconButton Icon="@Icons.Material.Filled.Menu" Color="Color.Inherit" Edge="Edge.Start" OnClick="@ToggleDrawer"/>
			RatScanner
			<MudSpacer/>
			<MudIconButton Icon="@Icons.Custom.Brands.GitHub" Color="Color.Inherit" Edge="Edge.End" OnClick="@(() => OpenURL(RatScannerUI.GithubLink))"/>
			<MudIconButton Icon="@discordLogo" Edge="Edge.End" OnClick="@(() => OpenURL(RatScannerUI.DiscordLink))" Style="color: #5865f2"/>
			<MudIconButton Icon="@patreonLogo" Edge="Edge.End" OnClick="@(() => OpenURL(RatScannerUI.PatreonLink))" Style="color: #FF424D"/>
		</MudAppBar>
		<MudDrawer @bind-Open="@drawerOpen" Elevation="1" Anchor="Anchor.Left" Variant="@DrawerVariant.Responsive">
			<MudDrawerHeader LinkToIndex="true">
				<div>
					<img src="RatLogoMedium.png" width="20%" style="vertical-align: middle;"/>
					<span style="font-size: 150%; vertical-align: bottom;">
						Rat Scanner
						<span style="font-size: 50%;">
							<text>v</text>@RatScannerUI.GetType().Assembly.GetName().Version.ToString(3)
						</span>
					</span>
				</div>
			</MudDrawerHeader>
			<MudNavMenu>
				<MudNavLink Href="/app" Match="NavLinkMatch.All" Icon="@Icons.Filled.Dashboard">Dashboard</MudNavLink>
				@*<MudNavLink Match="NavLinkMatch.All" Icon="@Icons.Filled.ManageSearch">Lookup</MudNavLink>
                    <MudNavLink Match="NavLinkMatch.All" Icon="@Icons.Filled.LocationSearching">Tracking</MudNavLink>*@
				<MudNavGroup Title="Settings" Expanded="false" Icon="@Icons.Filled.Settings">
					<MudNavLink Href="/app/settings/general">General</MudNavLink>
					<MudNavLink Href="/app/settings/scanning">Scanning</MudNavLink>
					<MudNavLink Href="/app/settings/tracking">Tracking</MudNavLink>
					<MudNavLink Href="/app/settings/minimal">Minimal UI</MudNavLink>
				</MudNavGroup>
				@*<MudNavLink Match="NavLinkMatch.All" Icon="@Icons.Filled.ExitToApp">Exit</MudNavLink>*@
			</MudNavMenu>
		</MudDrawer>
		<MudMainContent Class="mt-2">
			@Body
		</MudMainContent>
	</MudLayout>
</div>

@code {

	[CascadingParameter]
	public Error Error { get; set; }

	private string patreonLogo = "<svg style=\"width:24px;height:24px\" viewBox=\"0 0 24 24\"><path fill=\"currentColor\" d=\"M14.82 2.41C18.78 2.41 22 5.65 22 9.62C22 13.58 18.78 16.8 14.82 16.8C10.85 16.8 7.61 13.58 7.61 9.62C7.61 5.65 10.85 2.41 14.82 2.41M2 21.6H5.5V2.41H2V21.6Z\" /></svg>";
	private string discordLogo = "<svg style=\"width:24px;height:24px\" viewBox=\"0 0 24 24\"><path fill=\"currentColor\" d=\"M22,24L16.75,19L17.38,21H4.5A2.5,2.5 0 0,1 2,18.5V3.5A2.5,2.5 0 0,1 4.5,1H19.5A2.5,2.5 0 0,1 22,3.5V24M12,6.8C9.32,6.8 7.44,7.95 7.44,7.95C8.47,7.03 10.27,6.5 10.27,6.5L10.1,6.33C8.41,6.36 6.88,7.53 6.88,7.53C5.16,11.12 5.27,14.22 5.27,14.22C6.67,16.03 8.75,15.9 8.75,15.9L9.46,15C8.21,14.73 7.42,13.62 7.42,13.62C7.42,13.62 9.3,14.9 12,14.9C14.7,14.9 16.58,13.62 16.58,13.62C16.58,13.62 15.79,14.73 14.54,15L15.25,15.9C15.25,15.9 17.33,16.03 18.73,14.22C18.73,14.22 18.84,11.12 17.12,7.53C17.12,7.53 15.59,6.36 13.9,6.33L13.73,6.5C13.73,6.5 15.53,7.03 16.56,7.95C16.56,7.95 14.68,6.8 12,6.8M9.93,10.59C10.58,10.59 11.11,11.16 11.1,11.86C11.1,12.55 10.58,13.13 9.93,13.13C9.29,13.13 8.77,12.55 8.77,11.86C8.77,11.16 9.28,10.59 9.93,10.59M14.1,10.59C14.75,10.59 15.27,11.16 15.27,11.86C15.27,12.55 14.75,13.13 14.1,13.13C13.46,13.13 12.94,12.55 12.94,11.86C12.94,11.16 13.45,10.59 14.1,10.59Z\" /></svg>";

	bool drawerOpen = true;

	private void OpenURL(string url)
	{
		var psi = new ProcessStartInfo
		{
			FileName = url,
			UseShellExecute = true,
		};
		Process.Start(psi);
	}

	void ToggleDrawer()
	{
		drawerOpen = !drawerOpen;
	}

}
